package io.renren.modules.sys.service.impl;

import io.renren.modules.sys.entity.SysUserEntity;
import io.renren.modules.sys.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.sys.dao.XuanquDao;
import io.renren.modules.sys.entity.XuanquEntity;
import io.renren.modules.sys.service.XuanquService;

import javax.annotation.Resource;


@Service("xuanquService")
public class XuanquServiceImpl extends ServiceImpl<XuanquDao, XuanquEntity> implements XuanquService {

    @Resource
    XuanquDao xuanquDao;
    @Autowired
    SysUserService sysUserService;
    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<XuanquEntity> page = this.page(
                new Query<XuanquEntity>().getPage(params),
                new QueryWrapper<XuanquEntity>()
        );

        for  ( XuanquEntity entity:page.getRecords()) {
            SysUserEntity userEntity2 = sysUserService.getById(entity.getResuser());
            if (userEntity2 != null) {
                entity.setResusername(userEntity2.getRealname());
            }


        }
        return new PageUtils(page);
    }

    @Override
    public List<XuanquEntity> listxuanqu(Map<String, Object> params) {
        return xuanquDao.selectList( new QueryWrapper<XuanquEntity>());
    }

}
